package com.jyy.prefabricated.service;

import com.jyy.prefabricated.entity.StudentQuestionNote;
import com.jyy.prefabricated.exception.CustomException;
import com.jyy.prefabricated.mapper.StudentQuestionNoteMapper;
import com.jyy.prefabricated.mapper.StudentQuestionNoteMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * @version 1.0.0
 * @author: zjj
 */

@Service
public class StudentQuestionNoteService {

    @Autowired
    private StudentQuestionNoteMapper studentQuestionNoteMapper;

    /**
     * 新增
     * @param studentQuestionNote
     * @return
     */
    public Integer insert(StudentQuestionNote studentQuestionNote){
        studentQuestionNoteMapper.insert(studentQuestionNote);
        return studentQuestionNote.getId();
    }

    /**
     * 更新
     * @param studentQuestionNote
     * @return
     */
    public int update(StudentQuestionNote studentQuestionNote){
        if(studentQuestionNote.getId() == null){
            throw new CustomException("参数id不能为空");
        }
        return studentQuestionNoteMapper.updateByPrimaryKeySelective(studentQuestionNote);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    public int delete(Integer id){
        return studentQuestionNoteMapper.deleteByPrimaryKey(id);
    }

    /**
     * 根据id查询
     * @param id
     * @return
     */
    public StudentQuestionNote selectById(Integer id){
        return studentQuestionNoteMapper.selectByPrimaryKey(id);
    }
}
